#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int m, n, t, k, cnt = 0, flag = 0;
	cin>>m>>n;
	vector<int>p[m];
	for(int i = 0; i < n; i++){
		cin>>t;
		p[t%m].push_back(t);
	}
	cin>>k;
	for(int i = 0; i < p[k%m].size(); i++){
		cnt++;
		if(p[k%m][i] == k){
			flag = 1;
			break;
		}
	}
	if(flag)cout<<k%m<<","<<cnt;
	else cout<<-1;
	return 0;
}
